<div id="see_all_ajax">
<?php
    $dbwall = $this->database->t_wall;
    $dbuser = $this->database->t_user;
    $dbcomment = $this->database->t_comment;
    $dbcommentwall = $this->database->t_comment_wall;
    
    $query = "SELECT * FROM ".$dbwall."
        INNER JOIN ".$dbuser."
        ON ".$dbwall.".from_username = ".$dbuser.".username
        WHERE ".$dbwall.".to_username='".$this->view_profile['username']."'
        ORDER BY ".$dbwall.".id DESC";
    $result = $this->database->execQuery($query);
    $count = mysql_num_rows($result);

    if (!isset($_GET['m'])) {
        if ($count<5) {
            $count = $count;
        }
        else {
            $count = 5;
        }
    }
    for ($i=0;$i<$count;$i++) {
?>
<div class="wall_wrap">
    <div class="wall_share">

        <div class="wall_share_content">
            <div class="bar"></div>
            <div class="image_profile_thumb">
                <a href="profile.php?id=<?php echo mysql_result($result, $i, $dbwall.".from_username"); ?> ">
                    <img alt="profile" src="<?php echo mysql_result($result, $i, $dbuser.".img_location"); ?>"/>
                </a>
            </div>
            <div class="wall_content_wrap">
                <div class="idelete">
                    <?php if((mysql_result($result, $i, $dbuser.".username")==$this->session->username) || ($this->session->username==$this->view_profile['username'])) { ?>
                    <a href="process/delete.php?ref=wall&user=<?php echo $this->view_profile['username']; ?>&id=<?php echo mysql_result($result, $i, $dbwall.".id"); ?>">
                        <img alt="delete" title="delete" src="res/img/delete.gif" />
                    </a>
                    <?php } ?>
                </div>
                <div class="icontent">
                    <a href="profile.php?id=<?php echo mysql_result($result, $i, $dbuser.".username"); ?> ">
                        <?php echo mysql_result($result, $i, $dbuser.".fullname"); ?>
                    </a>
                    <?php echo mysql_result($result, $i, $dbwall.".content"); ?>
                </div>
                <div class="idate_wall"><?php echo mysql_result($result, $i, $dbwall.".date"); ?></div>
            </div>
            <div class="clear_both"></div>
        </div>
<?php
    $queryc = "SELECT * FROM ".$dbcomment."
        INNER JOIN ".$dbuser."
        INNER JOIN ".$dbcommentwall."
        ON (".$dbcomment.".username = ".$dbuser.".username AND
            ".$dbcomment.".id = ".$dbcommentwall.".id_comment)
        WHERE ".$dbcommentwall.".id_wall='".mysql_result($result, $i, $dbwall.".id")."'
        ORDER BY ".$dbcomment.".id ASC";
    $resultc = $this->database->execQuery($queryc);
    $countc = mysql_num_rows($resultc);

    for ($ic=0;$ic<$countc;$ic++) {
?>
        <div class="wall_share_comment">
            <div class="image_profile_thumb">
                <a href="profile.php?id=<?php echo mysql_result($resultc, $ic, $dbuser.".username"); ?> ">
                    <img alt="profile" src="<?php echo mysql_result($resultc, $ic, $dbuser.".img_location"); ?>" width="40" height="40"/>
                </a>
            </div>
            <div class="comment_content_wrap">
                <div class="idelete">
                    <?php if((mysql_result($resultc, $ic, $dbuser.".username")==$this->session->username) || ($this->session->username==$this->view_profile['username'])) { ?>
                    <a href="process/delete.php?ref=comment_wall&user=<?php echo $this->view_profile['username']; ?>&id=<?php echo mysql_result($resultc, $ic, $dbcomment.".id"); ?>">
                        <img alt="delete" title="delete" src="res/img/delete.gif" />
                    </a>
                    <?php } ?>
                </div>
                <div class="icontent">
                    <a href="profile.php?id=<?php echo mysql_result($resultc, $ic, $dbuser.".username"); ?> ">
                        <?php echo mysql_result($resultc, $ic, $dbuser.".fullname"); ?>
                    </a>
                    <?php echo mysql_result($resultc, $ic, $dbcomment.".content"); ?>
                </div>
                <div class="idate_comment"><?php echo mysql_result($resultc, $ic, $dbcomment.".date"); ?></div>
            </div>
            <div class="clear_both"></div>
        </div>
       
            
<?php
    }

    if ($this->isShow()) {
    $linkComment = "process/post_comment.php?ref=wall&id=".$this->view_profile['username'];
?>
        <form name="wall_comment" id="wall_comment" action=<?php echo $linkComment; ?> method="post">
        <div class="wall_share_comment_write">
            <textarea name="wall_comment_write" rows="3" cols="20" onclick="javascript:this.value=null;">Comment...</textarea>
            <input type="hidden" name="username" value="<?php echo $this->session->username; ?>" />
            <input type="hidden" name="wall_id" value="<?php echo mysql_result($result, $i, $dbwall.".id"); ?>" />
            <div class="submit_wrap">
                <input type="submit" value="comment" />
            </div>
        </div>
        </form>
<?php
    }
?>
    </div>

    
</div>

<?php
    }
?>
    <?php
    if (!isset($_GET['m'])) { ?>
         <div class="see_all">
            <a onclick="linkOnClickSeeAllWall('<?php echo $this->view_profile['username']?>','all',event)" href="#">
                See All
            </a>
        </div>
        <div class="clear_both"></div>
    <?php }
    ?>
</div>
<script type="text/javascript" src="script/AJAX.js"></script>